package io.kiki.sba.registry.common.model;

import lombok.Getter;
import lombok.Setter;

import java.io.Serializable;
import java.util.Objects;

@Setter
@Getter
public final class ClientInterfaceId implements Serializable {
    private final String hostAddress;
    private final long timestamp;
    private final int pid;
    private final int rand;

    public ClientInterfaceId(String hostAddress, long timestamp, int pid, int rand) {
        this.hostAddress = hostAddress;
        this.timestamp = timestamp;
        this.pid = pid;
        this.rand = rand;
    }


    @Override
    public boolean equals(Object o) {
        if (this == o)
            return true;
        if (!(o instanceof ClientInterfaceId))
            return false;
        ClientInterfaceId clientInterfaceId = (ClientInterfaceId) o;
        return timestamp == clientInterfaceId.timestamp && pid == clientInterfaceId.pid && rand == clientInterfaceId.rand && Objects.equals(hostAddress, clientInterfaceId.hostAddress);
    }

    @Override
    public int hashCode() {
        return Objects.hash(hostAddress, timestamp, pid, rand);
    }


}
